﻿#include <iostream>
#include "chmsnetworkbase.h"
#include <chmslog.h>

#include <string.h>


/*
 * 对象计数器
 * */
int ChMSNetWorkBase::sNewCounter = 0;

ChMSNetWorkBase::ChMSNetWorkBase()
{
    // 初始化 Winsock
    if (iResult != 0) {
        //printf("WSAStartup failed: %d\n", iResult);
        std::cout << "xinxi:" << iResult << std::endl;
        return;
    }
}

ChMSNetWorkBase::~ChMSNetWorkBase()
{

}

void ChMSNetWorkBase::funCreateSocket()
{

}

/*
 * 对象计数器 取数
 * */
int ChMSNetWorkBase::sFunGetCounter()
{
    return sNewCounter;
}

/*
 * 重载 new
 * */
void *ChMSNetWorkBase::operator new(size_t s)
{
    ++sNewCounter;
    // 程序刚启动时加载配置文件之前是不显示的，因为debug开关标识还未被读取
    std::string str1 = "new of ChMSNetWorkBase : ";
    ChMSLog::funVoidViewCounter(str1,sNewCounter);
    return ::operator new(s);
}

/*
 * 重载 new
 * */
void *ChMSNetWorkBase::operator new(size_t s,void * p)
{
    ++sNewCounter;
    // 程序刚启动时加载配置文件之前是不显示的，因为debug开关标识还未被读取
    std::string str1 = "new of ChMSNetWorkBase : ";
    ChMSLog::funVoidViewCounter(str1,sNewCounter);
    return ::operator new(s,p);
}

/*
 * 重载 delete
 * */
void ChMSNetWorkBase::operator delete(void *ptr)
{
    --sNewCounter;
    std::string str1 = "delete of ChMSNetWorkBase : ";
    ChMSLog::funVoidViewCounter(str1,sNewCounter);
    return ::operator delete(ptr);
}
